const deskRecommendItem = {
  state: {
    recommendMenu: []
  },
  mutations: {
    PUT_RECOMMEND_MENU: function (state, data) {
      state.recommendMenu = data
    },
    CHANGE_RECOMMEND_MENU: function (state, goodsId) {
      let checkIndex = state.recommendMenu.indexOf(goodsId)
      if (checkIndex > -1) {
        // this.$alert('该产品已加入菜单', '提示', {
        //   confirmButtonText: '确定'
        // })
      } else {
        state.recommendMenu.push(goodsId)
        sessionStorage.setItem('recommendMenu', JSON.stringify(state.recommendMenu))
      }
    },
    SPLICE_RECOMMEND_MENU: function (state, index) {
      state.recommendMenu.splice(index, 1)
      sessionStorage.setItem('recommendMenu', JSON.stringify(state.recommendMenu))
    }
  },
  getters: {
    getRecommendMenu: function (state) {
      return state.recommendMenu
    }
  },
  actions: {
    changeRecommendMenu ({ commit }, data) {
      commit('CHANGE_RECOMMEND_MENU', data)
    },
    spliceRecommendMenu ({ commit }, data) {
      commit('SPLICE_RECOMMEND_MENU', data)
    },
    putRecommendMenu ({ commit }, data) {
      commit('PUT_RECOMMEND_MENU', data)
    }
  }
}
export default deskRecommendItem
